package com.hzdl.order.controller;

import com.hzdl.order.entity.Order;
import com.hzdl.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    
    @Autowired
    private OrderService orderService;
    
    @GetMapping("/all")
    public List findAll() {
        return orderService.findAll();
    }
    
    @GetMapping("/one")
    public Object findById(@RequestParam("id") Integer id) {
        return orderService.findById(id);
    }
    
    @PostMapping
    public Order createOrder(@RequestBody Order order) {
        return orderService.createOrder(order);
    }

    @GetMapping("/test")
    public String test() {
        return "Order service is running!";
    }
}
